import request from '@/utils/request'
// 获取角色列表
export const getRolesAPI = ({ page, pageSize: pagesize }) => {
  return request({
    url: '/sys/role',
    method: 'get',
    params: {
      page,
      pagesize
    }
  })
}
// 新增角色
export const postRoleAPI = (data) => {
  return request({
    url: '/sys/role',
    method: 'post',
    data
  })
}
// 删除角色
export const delRoleAPI = (id) => {
  return request({
    url: '/sys/role/' + id,
    method: 'delete'
  })
}
// 修改角色
export const putRoleAPI = (id, { name, description, state }) => {
  return request({
    url: '/sys/role/' + id,
    method: 'put',
    data: {
      name,
      description,
      state: Number(state),
      id
    }
  })
}

// 获取已启用的角色列表
export const enabledRoleList = () => {
  return request({
    url: '/sys/role/list/enabled',
    method: 'get'
  })
}
// 分配权限
export const assignPremAPI = (id, permIds) => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data: {
      id,
      permIds
    }
  })
}
// 获取角色详情
export const getRoleDetails = (id) => {
  return request({
    url: '/sys/role/' + id,
    method: 'get'
  })
}
